// 缺点：调用方法都需要传递model
const mongoose = require("mongoose");
async function connect(){
	if(mongoose.connection.readyState === 1) return;
	return mongoose.connect("mongodb://127.0.0.1:27017/weibo",{
		serverSelectionTimeoutMS:1000
	})
}

module.exports = {
	async find(model){
		await connect();
		return model.find();
	},
	async count(model){
		await connect();
		return model.count();
	}
}


